home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C- WorkDisk V.adf / iff / plop.c < prev    next >
C/C++ Source or Header  |  1987-02-15  |  4KB  |  166 lines

  1. #include    <exec/types.h>
  2. #include     <exec/nodes.h>
  3. #include    <exec/libraries.h>
  4. #include    <graphics/gfx.h>
  5. #include    <graphics/rastport.h>
  6. #include    <graphics/text.h>
  7. #include    <intuition/intuition.h>
  8. #include     <stdio.h>
  9. #include     "df1:iff/jiff.c"
  10.  
  11.  
  12.  
  13.  
  14. /*This should be in exec/libraries.h */
  15. extern struct Library *OpenLibrary();
  16.  
  17. /*This should be in intuition/intuition.h */
  18. extern struct Screen *OpenScreen();
  19.  
  20. /* These are the bases for the libraries you need to do any graphics
  21.    much at all and still multi-task */
  22. struct Library *GfxBase = NULL;
  23. struct Library *LayersBase = NULL;
  24. struct Library    *IntuitionBase = NULL;
  25.  
  26. /* Well the workbench Screen isn't 320x200x5 so...*/
  27. struct Screen *PlopScreen = NULL;
  28.  
  29. /* Just one font for me... not static cause you might want it
  30.    in your menu modules. */
  31. struct TextAttr PlopFont =
  32.     {
  33.     "topaz.font",  /* I think this is the ROM font */
  34.     8,
  35.     0,
  36.     0,
  37.     };
  38.  
  39. /* a NewScreen - I don't know what half of this means either */
  40. static
  41. struct NewScreen PlopNewScreen =
  42.     {
  43.     0, 0, XMAX, YMAX, PLANES,
  44.     0, 1,
  45.     0,
  46.     CUSTOMSCREEN,
  47.     &PlopFont,
  48.     "Plop on Top",
  49.     NULL,
  50.     NULL,
  51.     };
  52.  
  53. /* To use clip blit need a RastPort.  Pretty useless, a BitMap should
  54.    be enough I think ... or anyway something a little less massive */
  55. struct RastPort PlopRastPort;
  56.  
  57. void
  58. put_ea_cmap(cmap, colors)
  59. unsigned char *cmap;
  60. long colors;
  61. {
  62. long i;
  63. unsigned long r, g, b;
  64.  
  65. if (colors > 32)    /*color clipping*/
  66.     colors = 32;
  67.  
  68. /* This loop is modified to work with Aztec 3.4a 32bit by J. Van Houtven */
  69. /* Modification Date : 20 July 1987 */
  70.  
  71. for (i=0; i<colors; i++)
  72.     {
  73.          r= *cmap++ >> 4;
  74.          g= *cmap++ >> 4;
  75.          b= *cmap++ >> 4;
  76.          SetRGB4(&PlopScreen->ViewPort,i,(long)r,(long)g,(long)b);
  77.     }
  78. }
  79.  
  80. /* back out backwards */
  81. void
  82. plop_cleanup()
  83. {
  84. if (PlopScreen != NULL)
  85.     CloseScreen(PlopScreen);
  86. if (IntuitionBase != NULL)
  87.     CloseLibrary(IntuitionBase);
  88. if (LayersBase != NULL)
  89.     CloseLibrary(LayersBase);
  90. if (GfxBase != NULL)
  91.     CloseLibrary(GfxBase);
  92. }
  93.  
  94. main(argc, argv)
  95. int argc;
  96. char *argv[];
  97. {
  98. int i;
  99. struct ILBM_info *info;
  100.  
  101. /*Before we can do ANYTHING have to get our libraries... */
  102. if ((GfxBase =  OpenLibrary("graphics.library", (long)0)) == NULL)
  103.     {
  104. #ifdef PARANOID
  105.     printf("Can't open Graphics Library\n");
  106. #endif PARANOID
  107.     return(-1);
  108.     }
  109.  
  110. if ((LayersBase =  OpenLibrary("layers.library", (long)0)) == NULL)
  111.     {
  112. #ifdef PARANOID
  113.     printf("Can't open Layers Library\n");
  114. #endif PARANOID
  115.     plop_cleanup();
  116.     return(-2);
  117.     }
  118.  
  119. /* Two for Dale and one for RJ */
  120. if ((IntuitionBase =  OpenLibrary("intuition.library",(long) 0)) == NULL)
  121.     {
  122. #ifdef PARANOID
  123.     printf("Can't open Intuition Library\n");
  124. #endif PARANOID
  125.     plop_cleanup();
  126.     return(-3);
  127.     }
  128.  
  129. if ( (PlopScreen = OpenScreen(&PlopNewScreen) ) == NULL)
  130.     {
  131. #ifdef PARANOID
  132.     printf("OpenScreen failed\n");
  133. #endif PARANOID
  134.     plop_cleanup();
  135.     return(-4);
  136.     }
  137.  
  138. InitRastPort(&PlopRastPort);
  139. /* PlopRastPort.Mask = (1<<PLANES)-1; */
  140. /*just play it safe in case someone tries to load 6 bit planes...*/
  141.  
  142. for (i=1; i<argc; i++)
  143.     {
  144. #ifdef DEBUG
  145.     puts(argv[i]);
  146. #endif DEBUG
  147.     if ( (info = read_iff(argv[i], 0) ) != NULL)
  148.         {
  149.         put_ea_cmap(&info->cmap, (1 << info->bitmap.Depth));
  150.         PlopRastPort.BitMap = &info->bitmap;
  151.         ClipBlit( &PlopRastPort, (long)0, (long)0,
  152.             &PlopScreen->RastPort, (long)info->header.x, (long)info->header.y,
  153.             (long)info->header.w, (long)info->header.h, (long)COPY_MINTERM);
  154.         Delay( (long)250);  /*pause for a couple seconds */
  155.         free_planes(&info->bitmap);
  156.         }
  157. #ifdef PARANOID
  158.     else
  159.         printf("couldn't load %s as an IFF file\n");
  160. #endif PARANOID
  161.     }
  162. plop_cleanup();
  163. }
  164.  
  165.  
  166.